// pages/index/index.js
var app = getApp()
const db = wx.cloud.database() 
Page({

    /**
     * 页面的初始数据
     */
    data: {
        users: [],
		swiperUsers:[],
		recommendTeams:[],
		recommendMatchs:[]
    },
    openNewTeam(e) {
        wx.navigateTo({
            url: '/pages/newTeam/newTeam',
        })
    },
    openTeam(e) {
        wx.navigateTo({
            url: '/pages/team/team',
        })
    },
    openMatch(e) {
        wx.navigateTo({
            url: '/pages/match/match',
        })
    },
    openPersonList(e) {
        wx.navigateTo({
            url: '/pages/personList/personList',
        })
    },
	//
	getRecommendTeams(){
		wx.cloud.callFunction({
			name:'getRecommendTeams'
		}).then(res=>{
			console.log(res)
			this.setData({
				recommendTeams: res.result
			})
		})
	},
	//
	getRecommendMaths() {
		wx.cloud.callFunction({
			name: 'getRecommendMatch'
		}).then(res => {
			console.log(res)
			this.setData({
				recommendMatchs: res.result
			})
		})
	},
	//轮播图信息获取
    getSwiperUsers() {
        wx.cloud.callFunction({
            name: "getSwiperUsers"
        }).then(res => {
            this.setData({
                swiperUsers: res.result.data
            })
        })
    },
	//为你找到人物推荐
    getRecommendPeople() {
        wx.cloud.callFunction({
            name: "getRecommendPeople"
        }).then(res => {
            console.log(res)
            let data = res.result
            this.setData({
                recommendUsers: data
            })
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
		let that = this
		that.getSwiperUsers()
		that.getRecommendPeople()
		that.getRecommendTeams()
		that.getRecommendMaths()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
       
    },

})